import { DataTypes, Model } from 'sequelize'
import sequelize from './db'

export interface IBigModelConfig {
    id: number
    name: string
    sdk: string
    baseURL: string
    apiKey: string
    model: string
    type: 'chat' | 'embed'
}

class BigModelConfig extends Model {
    declare id: number
    declare name: string
    declare sdk: string
    declare baseURL: string
    declare apiKey: string
    declare model: string
    declare type: 'chat' | 'embed'
}

BigModelConfig.init(
    {
        id: {
            type: DataTypes.INTEGER,
            primaryKey: true,
            autoIncrement: true,
        },
        name: {
            type: DataTypes.STRING,
            comment: '名称',
        },
        type: {
            type: DataTypes.STRING,
            defaultValue: 'chat',
            comment: '类型, 聊天模型chat或者向量化模型embed',
        },
        sdk: {
            type: DataTypes.STRING,
            defaultValue: 'ollama',
            comment: 'sdk类型, ollama或者openai',
        },
        model: {
            type: DataTypes.STRING,
            comment: '模型名称',
        },
        apiKey: {
            type: DataTypes.STRING,
            comment: 'apiKey',
        },
        baseURL: {
            type: DataTypes.STRING,
            comment: 'baseURL',
        },
    },
    {
        // 这是其他模型参数
        sequelize, // 我们需要传递连接实例
        modelName: 'bigmodelconfig', // 我们需要选择模型名称
        paranoid: true,
    }
)

export default BigModelConfig
